package com.sunday.authorization.mock.oauth2.server.constants;


public interface RedisOAuth2Constants {


    /***********************************    redis    *****************************************/

    String CACHE_TOKEN_PREFIX = "Oauth2:";

    /** 贯穿流程的 id */
    String ID_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}id_to_authorization:";

    static String getIdToAuthorization(String id) {
        return ID_TO_AUTHORIZATION + id;
    }

    /** 存储处于初始化状态或尚未完全完成的授权信息 */
    String STATE_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}state_to_authorization:";

    static String getStateToAuthorization(String state) {
        return STATE_TO_AUTHORIZATION + state;
    }

    /**
     * 未完成授权 code
     */
    String CODE_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}code_to_authorization:";

    static String getCodeToAuthorization(String state) {
        return CODE_TO_AUTHORIZATION + state;
    }

    /** 完成授权 访问token */
    String ACCESS_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}access_to_authorization:";

    static String getAccessToAuthorization(String accessToken) {
        return ACCESS_TO_AUTHORIZATION + accessToken;
    }

    /** 完成授权 刷新token */
    String REFRESH_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}refresh_to_authorization:";

    static String getRefreshToAuthorization(String refreshToken) {
        return REFRESH_TO_AUTHORIZATION + refreshToken;
    }

    /** 登录账号 principalName */
    String PRINCIPAL_NAME = STR."\{CACHE_TOKEN_PREFIX}principalName:";

    static String getPrincipalName(String principalName) {
        return PRINCIPAL_NAME + principalName;
    }

}
